<template>
	<el-form ref="form" :model="form" label-width="80px">
		<el-form-item label="跟进方式">
			<el-select v-model="followWay" placeholder="请选择跟进方式">
				<el-option label="微信沟通" value="微信沟通"></el-option>
				<el-option label="QQ沟通" value="QQ沟通"></el-option>
				<el-option label="线下沟通" value="线下沟通"></el-option>
				<el-option label="电话沟通" value="电话沟通"></el-option>
				<el-option label="邮件沟通" value="邮件沟通"></el-option>
			</el-select>
		</el-form-item>
		<el-form-item label="跟进时间">
			<el-col :span="16">
				<el-date-picker type="datetime" placeholder="选择跟进时间" v-model="followTime"
					style="width: auto;"></el-date-picker>
			</el-col>
		</el-form-item>
		<el-form-item label="跟进记录">
			<el-input type="textarea" v-model="followLog"  placeholder="请输入备注"></el-input>
		</el-form-item>
		<el-form-item>
			<el-button type="primary" @click="onSubmit">立即跟进</el-button>
			<el-button @click="back()">取消</el-button>
		</el-form-item>
	</el-form>
</template>

<script>
	export default {
		data() {
			return {
				userId: 0,
				customId: 0,
				followLog: '',
				followWay: '',
				followTime: ''
			}
		},
		onLoad(options) {
			this.userId = uni.getStorageSync('id')
			this.customId = options.customId;
			console.log(this.userId + ' ' + this.customId);
		},
		methods: {
			onSubmit() {
				function timestampToTime(timestamp) {
					var date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
					var Y = date.getFullYear() + '-';
					var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
					var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
					var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
					var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
					var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
					return Y + M + D + h + m + s;
				}
				this.followTime = timestampToTime(this.followTime)
				console.log(this.userId + ' ' + this.customId + ' ' + this.followWay + ' ' + this.followLog + ' ' + this
					.followTime)
				// 新增跟进信息
				uni.request({
					url: 'http://localhost:8089/crmdemo/followinfo/saveFollowinfo', //仅为示例，并非真实接口地址。
					data: {
						userId: this.userId,
						customId: this.customId,
						followLog: this.followLog,
						followWay: this.followWay,
						followTime: this.followTime
					},
					success: (res) => {
						console.log(res);
						if (res.data.status == "000000") {
							uni.showToast({
								title: "新增跟进记录信息成功",
								duration: 2000
							})
							setTimeout(() => {
								uni.reLaunch({
									url: 'customDetail?customId='+this.customId
								})
							}, 2000)
						} else {
							this.$modal.msgError("新增跟进记录信息失败")
						}
					}
				});
			},
			back(){
				uni.navigateTo({
					url: 'customDetail?customId='+this.customId
				})
			}

		}

	}
</script>

<style>

</style>